package GUI;

import java.awt.*;
import javax.swing.*;
import Socket.Client;


public class ClientFrame extends JFrame {

	private static final long serialVersionUID = -3268821053244293575L;	

	private final int width = 800, height = 480;
	
	Client client;
	String username;
	QueryPanel query;
	TablePanel table;
	TreePanel tree;
	MessageText message;
	
	public ClientFrame(Client client, String username) {
		super("miniDB");
		setLayout(null);
        setIconImage (getToolkit().getImage ("img/logo_1.png"));
        this.setResizable(false);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setSize(width, height);
		
		this.client = client;
		this.username = username;
		
		initComponent();
		
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation (d.width / 2 - width / 2, d.height / 2 - height / 2);
		this.setVisible(true);
	}
	
	private void initComponent() {
		
		message = new MessageText(new JTextArea());
		getContentPane().add(message);
		message.setBounds(530, 10, 250, 200);
		query = new QueryPanel(this);
		getContentPane().add(query);
		query.setBounds(230, 10, 300, 200);
		table = new TablePanel(this);
		getContentPane().add(table);
		table.setBounds(230, 220, 550, 220);
		tree = new TreePanel(this);
		getContentPane().add(tree);
		tree.setBounds(10, 10, 200, 430);
	}
}
